home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19950528-19950726 / 000080_news@columbia.edu_Wed Jun 7 15:20:31 1995.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Received: from apakabar.cc.columbia.edu by watsun.cc.columbia.edu with SMTP id AA14957
  2.   (5.65c+CU/IDA-1.4.4/HLK for <kermit.misc@watsun.cc.columbia.edu>); Wed, 7 Jun 1995 11:20:39 -0400
  3. Received: by apakabar.cc.columbia.edu id AA12736
  4.   (5.65c+CU/IDA-1.4.4/HLK for kermit.misc@watsun); Wed, 7 Jun 1995 11:20:37 -0400
  5. Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
  6. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  7. Newsgroups: comp.protocols.kermit.misc
  8. Subject: Re: Kermit as data-entry clerk
  9. Date: 7 Jun 1995 15:20:31 GMT
  10. Organization: Columbia University, New York City
  11. Lines: 87
  12. Message-Id: <3r4g3v$cdr@apakabar.cc.columbia.edu>
  13. References: <3r2avh$cdm@cmhcsys.cmhcsys.com>
  14. Nntp-Posting-Host: watsun.cc.columbia.edu
  15. Keywords: kermit variables
  16. Apparently-To: kermit.misc@watsun.cc.columbia.edu
  17.  
  18. In article <3r2avh$cdm@cmhcsys.cmhcsys.com>,
  19. Chuck Stickelman <chuck@cmhcsys.com> wrote:
  20. : We have a customer how needs to get information from our proprietary
  21. : database into a county-wide system.  Unfortunately, the county-wide
  22. : system does not allow batch transfers of any kind. Therefore, the 
  23. : customer has been paying a full-time employee to run a couple of
  24. : reports on our system and then re-key the data into the other database.
  25. : Needless to say, this is less than ideal.
  26. : I proposed that we output the data to a DOS file in a format Kermit
  27. : would like: {field data    }{more field data   }{even more...} etc.
  28. : No problem.  Then I thought we could use Kermit's 'read', 'assign'
  29. : and 'output' commands to fake the remote system into thinking a real
  30. : -live human was on the other end.  Something like:
  31. :  define parse assign \%a \%1, assign \%b \%2, assign \%c \%3, ...
  32. :  open somefile.dat
  33. :  read \%z
  34. :  parse \%z
  35. :  output \%a
  36. :  output \%b
  37. :  output \%c
  38. :  ...
  39. : However, the records in somefile.dat have too many fields (>35 in one
  40. : instance) and I'm running out of both temporary and permanent variables.
  41. : I've read the relevant pages in "Using MS-KERMIT" and understand that
  42. : there are 10 temporary variables (0-9) and 26 permanent variables (a-z),
  43. : but wonder if there's anyway I can "easily" change that or get around
  44. : those limitations!?
  45. Yes, there are many ways to do this.  First, two observations:
  46.  
  47.  1. If you are providing Kermit software to your customers, you have to
  48.     obtain written permission from the Office of Kermit Development and
  49.     Distribution at Columbia University.  Email to kermit@columbia.edu
  50.     for further information.
  51.  
  52.  2. You'll need version 3.14.
  53.  
  54. So you are saying that you can't do the obvious thing, namely:
  55.  
  56.     open somefile.dat
  57. :loop    read \%z
  58.     if fail goto done
  59.     output \%z           ; or "output \%z\13", etc, ...
  60.     goto loop
  61. :done
  62.  
  63. In other words, you have to send one "word" at a time?  One solution
  64. that suggests itself immediately is to create the original file in a
  65. different format, e.g. one field per line.  You just have to think up
  66. some convention for distinguishing between a field boundary and a record
  67. boundary.  (It's not clear to me from your description how you were
  68. doing this in the first place -- I don't see any kind of field or record
  69. delimiters in your example.)
  70.  
  71. MS-DOS Kermit 3.14 includes a full complement of string manipulation
  72. functions -- index, substring, replace, etc, that you should be able to
  73. use creatively to solve your problem.  For example (assuming fields are
  74. delimited by a single space):
  75.  
  76. :RECORDS
  77.   read \%a                           ; read a record
  78.   if fail goto done                  ; no more, we're finished
  79.  
  80. :FIELDS
  81.   assign \%j \flength(\%a)           ; length of record
  82.   if > \%j 0 goto gotfield           ; no (more) fields, get another
  83.   output ???                         ; send your record delimiter here
  84.   goto records                       ; go get next record
  85.  
  86. :GOTFIELD
  87.   assign \%i \findex({ },\%a,1)      ; got record, find first space
  88.   decrement \%i
  89.   if < \%i 1 asg \%i \%j             ; no spaces, must be last field
  90.   assign \%f \fsubstr(\%a,1,\%i)     ; get the field
  91.   output \%f                         ; send it (and add field delimiter)
  92.   increment \%i 2                    ; point past it
  93.   assign \%a \fsubstr(\%a,\%i)       ; and go get next field
  94.   goto fields
  95.  
  96. :DONE
  97.  
  98. See KERMIT.UPD for more info about string functions.
  99.  
  100. - Frank